var PersonModel = require('../model/PersonModel');

const PersonService = {
    addPerson: (person) => {
        return PersonModel.create(person)
    },
    updatePerson: (_id, person) => {
        return PersonModel.updateOne({_id}, person)
    },
    getPersonOrList: (_id) => {
        return _id ? PersonModel.find({_id}) : PersonModel.find({})
        // return PersonModel.find({_id});   // 失败
    },
    delPerson: (_id) => {
        return PersonModel.deleteOne({_id})
    },
    login: (person) => {
        return PersonModel.findOne(person)
    },
}

module.exports = PersonService